<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>Hello APP</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../css/aui.css" />
    <style type="text/css">
    html,body{
        height: 100%;
    }
    #wrap{
        height: 100%;
        display: -webkit-box;
        display: -webkit-flex;
        display: flex;
        -webkit-box-orient: vertical;
        -webkit-flex-flow: column;
               flex-flow: column;
    }
    
    #main{
        -webkit-box-flex: 1; 
        -webkit-flex: 1;
        flex: 1;
    }
    .search-input {
        height: 1.6rem;
        line-height: 1.6rem;
        background: #f5f5f5;
        border-radius: 30px;
        position: relative;
        font-family:"aui_iconfont" !important;
        text-align: left;
        padding-left: 1.5rem;
        color: #999999;
    }
    .search-input:after {
        position: absolute;
        left: 0;
        padding-left: 0.5rem;
        content: "\e615";
    }
    .icon {
       width: 1em; height: 1em;
       vertical-align: -0.2em;
       fill: currentColor;
       overflow: hidden;
    }

    </style>
</head>
<body>
    <header class="aui-bar aui-bar-nav" id="header">
        <a class="aui-btn aui-pull-left" tapmode onclick="closeWin()">
            <span class="aui-iconfont aui-icon-left"></span>
        </a>
        <div class="aui-title">待我审批</div>
        <a class="aui-pull-right aui-btn aui-btn-outlined" onclick="openWin('workflow_history')">
            <span class="aui-iconfont aui-icon-menu"></span>
        </a>
    </header>
    <div id="main">
            
    </div>
    <footer class="aui-bar aui-bar-tab" id="footer">
        <div class="aui-content">
            <ul class="aui-list aui-form-list">
                <li class="aui-list-item">
                    <div class="aui-list-item-inner aui-list-item-center aui-list-item-btn">
                        <div class="aui-btn aui-btn-info aui-margin-r-15" id="agree" style="display: block;" onclick="agree()">
                            <svg class="icon" aria-hidden="true">
                                <use xlink:href="#icon-dui"></use>
                            </svg>
                            同意
                        </div>
                        <div class="aui-btn aui-btn-primary aui-margin-r-15" id="send" style="display: none;" onclick="sendOther()">
                            <svg class="icon" aria-hidden="true">
                                <use xlink:href="#icon-dui"></use>
                            </svg>
                            转送
                        </div>
                        <div class="aui-btn aui-btn-danger aui-margin-l-15" onclick="reject()">
                            <svg class="icon" aria-hidden="true">
                                <use xlink:href="#icon-p-auditing-true"></use>
                            </svg>
                            驳回
                        </div>
                    </div>
                </li>
            </ul>
        </div>
    </footer>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/zepto.min.js" ></script>
<script type="text/javascript" src="../script/aui-toast.js" ></script>
<script type="text/javascript" src="../css/font/iconfont.js" ></script>
<script type="text/javascript">
    apiready = function(){
        //适配iOS 7+，Android 4.4+状态栏
        $api.fixStatusBar(header);
        openFrame('workflow_list_details');
    };

    function openFrame(name) {
        var header = $api.byId('header');
        var headerPos = $api.offset(header);
        var footer = $api.byId('footer');
        var footerPos = $api.offset(footer);
        var main = $api.byId('main');
        var mainPos = $api.offset(main);
        api.openFrame({
            name: name,
            url: name+'_frm.html',
            pageParam: {
                id : api.pageParam.id,
                type : api.pageParam.type,
                name : api.pageParam.name
            },
            rect: {
                x: 0,
                y: headerPos.h,
                w: 'auto',
                h: api.frameHeight-headerPos.h-footerPos.h
            }
        });
    }

    function sendOther() {
        api.execScript({
            frameName: 'workflow_list_details',
            script: 'sendOther();'
        });

        api.sendEvent({
            name: 'reloadWorkflow',
        });
    }

    // 转送回来的操作
    function selectUsers (user) {
        $('#agree').css({'display' : 'none'});
        $('#send').css({'display' : 'block'});
    }
    

    function agree() {
        api.execScript({
            frameName: 'workflow_list_details',
            script: 'updateStatus(1);'
        });

        api.sendEvent({
            name: 'reloadWorkflow',
        });
    }

    function reject() {
        api.execScript({
            frameName: 'workflow_list_details',
            script: 'updateStatus(2);'
        });

        api.sendEvent({
            name: 'reloadWorkflow',
        });
    }

    // 打开win
    function openWin(name) {
        api.openWin({
            name: name,
            url: name+'_win.html',
            pageParam: {
                id : api.pageParam.id,
                type : api.pageParam.type,
            },
        });
    }

    function closeWin () {
        /*api.execScript({
            name : 'workflow',
            frameName: 'workflow_list',
            script: 'reload()'
        });*/
        
        api.closeWin();
    }

</script>
</html>